#!/usr/bin/python
# -*- coding: utf-8 -*-


import pandas
import os
import sys
import csv


file_list = list()

if len(sys.argv) < 2:
	print 'The arguments length is less then 2...'

for file_path in sys.argv[1:]:
	file_list.append(file_path)

project_path = os.path.dirname(os.path.abspath(__file__))
writer = pandas.ExcelWriter(os.path.join(project_path, 'data.xlsx'), engine='xlsxwriter')

df = pandas.DataFrame()
item_wl = list()
for i, item_file_path in enumerate(file_list[0:]):
	item_file_reader = csv.reader(file(item_file_path, 'rb'), dialect='excel')
	item_i = list()
	for j, item_line in enumerate(item_file_reader):
		if j <= 2:
			continue
		if i == 0:
			item_wl.append(item_line[0])
		item_i.append(item_line[1])
	bare_name = os.path.basename(item_file_path)
	df[bare_name] = item_i
df.index = item_wl

df.to_excel(writer, sheet_name='data')
writer.save()

raw_input('press any key to exit...')

# http://stackoverflow.com/questions/29974672/writing-pandas-dataframe-to-excel-with-different-formats-for-different-columns
# reindex_df = df.sort_index(axis=1)


























